﻿<%@ Page Title="地图显示" Language="C#" AutoEventWireup="true" Inherits="Wjtour.Web.Front.map" %>

<%@ Import Namespace="Wjtour.Domain" %>
<%@ Import Namespace="Wjtour.Common" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
    <style type="text/css">
        body, html
        {
            width: 100%;
            height: 100%;
            overflow: hidden;
            margin: 0;
            padding: 0;
        }

        #map
        {
            width: 650px;
            height: 323px;
            float: left;
            border-right: 0px solid #bcbcbc;
        }
    </style>
    <script src="js/jquery.js" type="text/javascript"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/api?v=1.5&ak=<%=BaiduKey%>"></script>
    <script type="text/javascript" src="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.js"></script>
    <link rel="stylesheet" href="http://api.map.baidu.com/library/SearchInfoWindow/1.5/src/SearchInfoWindow_min.css" />
    <title>SearchInfoWindow</title>
</head>
<body>
    <div id="map"></div>
    <script type="text/javascript">
        // 百度地图api功能
        var map = new BMap.Map('map');
        var poi = new BMap.Point(120.62, 31.32);
        map.centerAndZoom(poi, 16);
        map.enableScrollWheelZoom();
        var opts = { type: BMAP_NAVIGATION_CONTROL_SMALL }
        map.addControl(new BMap.NavigationControl(opts));

        var content = "<div style=\"margin:0;line-height:20px;padding:2px;\">" +
                        "<img src=\"<%=img%>\" alt=\"\" style=\"float:right;zoom:1;overflow:hidden;width:100px;height:100px;margin-left:3px;\"/>" +
                        '地址：<%=address%><br/>电话：<%=tel%><br/>简介：<%=introduce%>' +
                        "</div>";

        //创建检索信息窗口对象
        var searchInfoWindow = null;
        searchInfoWindow = new BMapLib.SearchInfoWindow(map, content, {
            title: "<%=title%>",      //标题
            width: 320,             //宽度
            height: 105,              //高度
            panel: "panel",         //检索结果面板
            enableAutoPan: true,     //自动平移
            searchTypes: [
                BMAPLIB_TAB_SEARCH,   //周边检索
                BMAPLIB_TAB_TO_HERE,  //到这里去
                BMAPLIB_TAB_FROM_HERE //从这里出发
            ]
        });

        var myGeo = new BMap.Geocoder();
        // 将地址解析结果显示在地图上,并调整地图视野
        myGeo.getPoint("<%=address.Replace("苏州市","").Replace("苏州","")%>", function (point) {
            if (point) {
                var marker = new BMap.Marker(point); //创建marker对象
                marker.enableDragging(); //marker可拖拽
                marker.addEventListener("click", function (e) {
                    searchInfoWindow.open(marker);
                })
                map.centerAndZoom(point, 16);
                map.addOverlay(marker); //在地图中添加marker
                searchInfoWindow.open(marker); //在marker上打开检索信息串口
            }
        }, "江苏省苏州市");

    </script>
</body>
</html>
